<template>
    <el-container>
        <el-header>
            <cli-title-student></cli-title-student>
        </el-header>
        <el-main>
            <div class="center">
                <el-row>
                    <p>当前知识库：{{repository}}</p>
                </el-row>
                <el-row>
                    <el-input
                            type="textarea"
                            :rows="3"
                            placeholder="请输入知识内容"
                            v-model="content">
                    </el-input>
                    <el-button type="primary" class="sendbutton" style="margin-top: 10px" @click="draft">添加知识内容
                    </el-button>
                </el-row>
            </div>
        </el-main>
        <el-footer>
            <page-footer></page-footer>
        </el-footer>
    </el-container>
</template>

<script>
    import CliTitleStudent from "../../../components/base/cliTitleStudent";
    import PageFooter from "../../../components/base/pageFooter";
    import POST from "../../../api/POST";
    import Cookies from "js-cookie";

    export default {
        name: "draftrepositorycontext",
        components: {PageFooter, CliTitleStudent},
        data() {
            return {
                cid: '',
                repository: '',
                uid: '',
                content: ''
            }
        }, methods: {

            draft() {
                let data = {
                    'id': this.uid,
                    'collectbox_id': this.cid,
                    'content': this.content
                };
                POST.addCollectboxContent(data).then(res => {

                })
                this.$router.push({path: '/personal/home'});
            }
        }, created() {
            this.cid = this.$route.params.cid;
            console.log(this.cid);
            this.info = Cookies.get('info');
            this.info = JSON.parse(this.info);
            this.uid = this.info.account;
        }
    }
</script>

<style scoped>
    .center {
        width: 700px;
        margin: 50px auto;
    }
</style>